package cn.orangeframe.neon.ui.model;

import lombok.Data;
import org.springframework.http.HttpStatus;

@Data
public class Response {

    private Integer code;

    private String msg;

    private Object data;

    public static Response success() {
        return new Response(HttpStatus.OK.value(), "操作成功", null);
    }

    public static Response success(Object data) {
        return new Response(HttpStatus.OK.value(), "操作成功", data);
    }

    public static Response success(String message, Object data) {
        return new Response(HttpStatus.OK.value(), message, data);
    }

    public static Response failed() {
        return new Response(HttpStatus.INTERNAL_SERVER_ERROR.value(), HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(), null);
    }

    public static Response failed(String message) {
        return new Response(HttpStatus.INTERNAL_SERVER_ERROR.value(), message, null);
    }

    public static Response failed(Object data) {
        return new Response(HttpStatus.INTERNAL_SERVER_ERROR.value(), HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(), data);
    }

    public Response(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
}
